<?php

class S1_head{
	var $logo ;
	var $width = "100%";
	var $lightMenuBGColor = "" ;
	var $lightMenuTxtColor = "" ;
	var $blurMenuBGColor = "" ;
	var $blurMenuTxtColor = "" ;

	var $lightMenuHeight = "20px";
	var $blurMenuHeight = "20px";
	var $menus = array() ;
	var $menuIndex = 0 ;

	function S1_head(){
		$this->lightMenuBGColor = getRGBColor(40);
		$this->lightMenuTxtColor = getRGBColor(100);
		$this->blurMenuBGColor = getRGBColor(85);
		$this->blurMenuTxtColor = getRGBColor(30);
	}


	function setLogo($logo){
		$this->logo = $logo ;
	}

	function addMenu($menu){
		$menu->setId($this->menuIndex);
		$this->menuIndex++;
		array_push($this->menus,$menu);
	}

	function getHTML($pageUrl){
		global $site_url , $site_name , $admin_email;

		$keyName = "button_menuIndex" ;
		$mIndex = get($keyName) ;

		if($mIndex != ""){
			$_SESSION[$keyName] = $mIndex;
		}else{
			$mIndex = 0 ;
		}
		if(isset($_SESSION[$keyName])){
			$mIndex = intval($_SESSION[$keyName]) ;
		}

		for($i=0;$i<count($this->menus);$i++){
			$c = substr_count($this->menus[$i]->url,$pageUrl) ;
			// print($pageUrl . "-----------". $this->menus[$i]->url);
			if($c > 0){
				$mIndex = $i ;
				$_SESSION["LAST_INDEX_PAGE"] = $pageUrl ;
				$_SESSION[$keyName] = $mIndex;
				break ;
			}
		}
		
		$menuCount = count($this->menus);

		$html = "";
		$html .= "<table cellspacing=0 cellpadding=0 width='100%' style='border:blue 0px solid;'>";

		$html .= "<tr>";
		$html .= "	<td rowspan='2' style='width:45%;'>";
		$html .= "		<div style='height:60px;text-align:right;padding:20px 40px 4px 20px;'><img src='". $this->logo ."'></img></div>";
		$html .= "	</td>";
		$html .= "	<td colspan='".($menuCount*2)."'>";
		$html .= "	</td>";
		$html .= "	<td rowspan='2' style='width:45%;text-align:left;padding-top:60px;padding-left:40px;'>";
		$html .=		getColorChooseTable() ;
		$html .= "	</td>";
		$html .= "</tr>";
		$html .= "<tr>";

		for($i=0;$i<count($this->menus);$i++){
			$len = strlen($this->menus[$i]->getName());

			$style = " style='border-left:". $this->blurMenuTxtColor ." 1px solid;border-right:". $this->blurMenuTxtColor ." 1px solid;border-top:". $this->blurMenuTxtColor ." 1px solid;border-bottom:". $this->blurMenuTxtColor ." 0px solid;text-align:center;padding-top:4px;cursor:pointer;background-color:". $this->blurMenuBGColor .";color:". $this->blurMenuTxtColor .";height:". $this->blurMenuHeight .";padding-left:8px;padding-right:8px;white-space:nowrap;'";

			if($mIndex == $i){
				$style = " style='border-left:". $this->blurMenuTxtColor ." 1px solid;border-right:". $this->blurMenuTxtColor ." 1px solid;border-top:". $this->blurMenuTxtColor ." 1px solid;text-align:center;padding-top:5px;cursor:pointer;background-color:". $this->lightMenuBGColor .";color:". $this->lightMenuTxtColor .";height:". $this->lightMenuHeight .";padding-left:8px;padding-right:8px;white-space:nowrap;'";
			}

			$html .= "	<td style='vertical-align:bottom;' onclick=\"go_url('". $this->menus[$i]->getUrl() ."?button_menuIndex=". $this->menus[$i]->getId() ."')\">";
			$html .= "		<div ". $style .">";
			$html .=			$this->menus[$i]->getName() ;
			$html .= "		</div>";
			$html .= "	</td>";
			$html .= "	<td style='vertical-align:bottom;border-bottom:". $this->blurMenuTxtColor ." 1px solid;'><div style='width:3px;'></div></td>";
		}

		$html .= "</tr>";
		$html .= "<tr>";
		$html .= "	<td colspan=".($menuCount*2+2)." style='height:3px;border-left:". $this->blurMenuTxtColor ." 1px solid;border-right:". $this->blurMenuTxtColor ." 1px solid;border-bottom:". $this->blurMenuTxtColor ." 1px solid;background-color:". $this->lightMenuBGColor .";'>";
		$html .= "	</td>";
		$html .= "</tr>";
		$html .= "</table>";
		return $html ;
	}
}

?>